<html>
<head>
<title>WIKINDX DOCUMENTATION</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="/wikindx2/docs/docs.css" type="text/css" />
</head>

<body bgcolor="#FFFFFF" text="#000000">
<h2>WIKINDX ~ Using Sessions</h2>
<p><a href="../classes/session/sessionClass.html">SESSION Class</a></p>

<p>WIKINDX uses sessions extensively for storage of default configuration, 
authorization, user preferences and for temporary storage of user input 
strings and the session class has a variety of methods for manipulating 
sessions.</p>

<p>All session variables in WIKINDX have a prefix which groups all variables of 
a certain type together.  For example, all session variables to do with 
authorization and default configuration have the prefix 'setup' and it is a 
simple matter to access and manipulate this group of variables using the session 
methods:
<pre>
	<a href="../classes/session/getarrayMethod.html">getArray('setup')</a>
	<a href="../classes/session/writearrayMethod.html">writeArray($assocArray, 'setup')</a>
	<a href="../classes/session/cleararrayMethod.html">clearArray('setup')</a></pre>

Currently used prefixes:<br />
<pre>
	'config' (temporary storage of admin configuration variables used when updating the WIKINDX configuration)
	'convert' (temporary storage of database conversion variables used when converting v1 database resources to v2)
	'exportRtf' (temporary storage for RTF export parameters)
	'exportHtml' (temporary storage for HTML export parameters)
	'import' (temporary storage of bibliography import parameters)
	'list' (all resource listing options)
	'mywikindx' (user bibliographies etc.)
	'news' (for news items)
	'preferences' (temporary storage of configuration variables used when updating WIKINDX user preferences)
	'resource' (temporary storage user resource input when creating or editing resources)
	'setup' (all authorization and configuration variables setup on script initialization)
	'sql' (SQL statements used when exporting the last resource select or list operation to RTF or BibTeX)
	'style' (temporary storage of variables used when creating/editing bibliographic styles)
	'cite' (temporary storage of variables used when creating/editing citation styles)
	'list' (temporary storage of variables used when listing bibliographies)
	'custom' (temporary storage of variables used when creating custom database fields)
	'bookmarks' (user bookmarks)<br>	'wp' (temporary storage of word processor variables)
	'exportPaper' (temporary storage for paper (SUWP) export parameters)
	'select' (temporary storage of resource select parameters)
	'search' (temporary storage of resource quick search parameters)
	'powerSearch' (temporary storage of resource power search parameters)
	'selectMeta' (temporary storage of metadata select parameters)
	'searchMeta' (temporary storage of metadata search parameters)
	'preview' (temporary storage of bibliographic style preview data)
	'basket' (temporary storage of a basket of resources)
	'emailFriend' (temporary storage of email message when sending resource link to a friend)
</pre>
</p>

<p>
Of the above, the following are set at system initialisation:
<pre>
	setup_language: the user's preferred localisation matching the folder name in <em>languages/</em>
	setup_style: the user's preferred bibliographic style
	setup_default: the user's preferred template/theme
	setup_paging: the user's preferred number of resources to display per page
	setup_pagingMaxLinks: the user's preferred number of paging links
	setup_stringLimit: the user's preferred maximum string length within form select boxes
	setup_notify: is email notification allowed when resources are added or edited? 0|1 for FALSE|TRUE (or not set)
	setup_title: the WIKINDX title (displayed on each page)
	setup_fileDeleteSeconds: number of seconds before exported files are scheduled for deletion
	setup_bibliographies: are there populated user bibliographies for viewing? 0|1 for FALSE|TRUE (or not set)
	setup_multiUser: is the WIKINDX in multi user mode? 0|1 for FALSE|TRUE (or not set)
	setup_readOnly: read only access? 0|1 for FALSE|TRUE
	setup_fileAttach: allow file attachments? 0|1 for FALSE|TRUE
	setup_fileViewLoggedOnOnly: allow only logged on users to view file attachments? 0|1 for FALSE|TRUE
	setup_news: are there news items available for viewing? 0|1 for FALSE|TRUE
<em>The following are set if setup_readOnly is not set (or is FALSE):</em>
	setup_superadmin: is the user the admin? 0|1 for FALSE|TRUE
	setup_userId: the user's ID number as found in the database table WKX_users
	setup_write: does this user have write/edit privileges? 0|1 for FALSE|TRUE
</pre>
</p>
<p>
The following may also be of interest:
<pre>
	sql_stmt: the complete SQL statement last used when displaying bibliographic lists (list by, select by, search or power search).
		This can be fed direct to the database once you have stripped slashes from it.
	sql_lastMulti: the type of the last bibliographic list display (list|select|search|powerSearch)
	sql_lastSolo: the resource ID (as in WKX_resource) of the last single resource view
	mywikindx_bibliography_use: the id of the bibliography (as in WKX_user_bibliography) that the user has chosen 
		to browse. This is not set (or is FALSE) if the master bibliography has been chosen for browsing instead.
	sql_lastMultiMeta: the last type of view for metadata (select|search).
</pre>
</p>
<p>
Note that SESSION::getVar(STRING: session variable) will return FALSE if the session variable is FALSE (or 0) <em>OR</em> the session variable is not set.
</p>

<h4>TIP:</h4>
<p>When displaying a form or processing user input, it is good practice to grab any needed/preset 
values from the database or from user form input and <b>immediately</b> write 
them all to the session with an appropriate prefix.  <b>Then</b>, create the 
HTML code for the form elements grabbing appropriate values from the <b>session</b> if 
needed.  </p>
<p>If the user makes an error on form input, this method makes it very easy to 
send the user back to the form with his/her pre-filled values grabbed from the 
session.
</p>
<p>i.e. Make it standard practice that preset values for form elements come 
<b>only</b> from the session (which may get its values from user form input or 
from the database) and <b>never</b> directly from user form input or the 
database.</p>

<p>An example of this can be found in CONFIG:</p>

When displaying the form for the first time, the program flow may be summarized 
thus:

<pre>
	<b><i>A:</i></b>
	<b>'config' prefixed variables in session?</b>
		<b>yes:</b> store session 'config_xxxx' variables in $array
		<b>no:</b> grab values from db table and place in $array and write 
		'config_xxxx' variables to session using $array
	<b>display form elements with values from $array</b>
	</pre>

and when accepting user input from the form:

<pre>
	<b><i>B:</i></b>
	<b>write user input to session with 'config' prefix</b>
	<b>user input correctly validated?</b>
		<b>no:</b> return to <b>A</b>
		<b>yes:</b> insert/update database</pre>


<p align="right"><a href="../index.html">WIKINDX home</a>
&nbsp;&nbsp;&nbsp;&nbsp;
<a href="index.html">WIKINDX usage</a>
&nbsp;&nbsp;&nbsp;&nbsp;
<a href="../classes/index.html">WIKINDX classes</a>
</p>
</body>
</html>
